﻿using System.Collections;
using java.util;

namespace MLSharp.Weka.Interop
{
	/// <summary>
	/// Contains extension methods to simplify working with 
	/// <see cref="Enumeration"/> objects.
	/// </summary>
	public static class EnumerationExtensions
	{
		/// <summary>
		/// Creates a <see cref="IEnumerable"/> wrapper
		/// around a <see cref="Enumeration"/>.
		/// </summary>
		/// <param name="enumeration"></param>
		/// <returns></returns>
		public static IEnumerable ToEnumerable(this Enumeration enumeration)
		{
			EnumeratorEnumerationAdapter adapter = new EnumeratorEnumerationAdapter(enumeration);

			while (adapter.MoveNext())
			{
				yield return adapter.Current;
			}
		}
	}
}
